﻿using System.Collections.Generic;

namespace OrderManage.Utility
{
    public class JsonHelper
    {
        /// <summary>
        /// 分页时拼接字符串
        /// </summary>
        /// <returns></returns>
        public static string Encode<T>(int total, IList<T> list)
        {
            var json = PluSoft.Utils.JSON.Encode(list);
            return "{\"total\":" + total + ",\"data\":" + json + "}";
        }

        /// <summary>
        /// 普通转换成json格式
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static string Encode<T>(IList<T> list)
        {
            return PluSoft.Utils.JSON.Encode(list);
        }

        /// <summary>
        /// 普通转换成json格式
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static string Encode(object model)
        {
            return PluSoft.Utils.JSON.Encode(model);
        }

        public static object Decode(string model)
        {
            return PluSoft.Utils.JSON.Decode(model);
        }
    }
}
